package etnorservice.etnor_service.mapper.projectMapper;



import etnorservice.etnor_service.domain.Project;
import etnorservice.etnor_service.domain.ProjectTag;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProjectTagMapper {
    @Insert("INSERT INTO project_tags(project_id, tag_name) VALUES(#{projectId}, #{tagName})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(ProjectTag tag);

    @Select("SELECT * FROM project_tags WHERE project_id = #{projectId}")
    List<ProjectTag> findByProjectId(Long projectId);

    @Delete("DELETE FROM project_tags WHERE project_id = #{projectId}")
    int deleteByProjectId(Long projectId);

    @Select("SELECT * FROM projects WHERE is_deleted = 0")
    List<Project> findAllProjects();
    /**
     * 获取所有唯一的标签名称
     */
    @Select("SELECT DISTINCT tag_name FROM project_tags ORDER BY tag_name")
    List<String> findAllUniqueTags();
}